<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script type="text/javascript">
		
	function foo() {
		var a = 'test';

		function bar() {
			console.log(a);
		}

		bar();
	}

	foo();



	function foo() {
		var a = 'test';

		function bar() {
			return a;
		}

		return bar;
	}

	var bar = foo();
	bar();

	function wait(message) {
		setTimeout(function() {
			console.log(message);
		}, 1000);
	}

	wait('hello, closure');


	(function() {
		var doc = document;

		var util = {
			byId: function(id) {
				return doc.getElementById(id);
			}
		};

		window.Util = util;
	})();

	Util.byId('hahah');


	(function() {
		var doc = document;

		var util = {
			byId: function(id) {
				return doc.getElementById(id);
			}
		};

		window.jQuery = util;
	})();

	jQuery.byId('hahah');


	</script>
	<p>请用 f12 查看此 html 的script标签</p>
</body>
</html>